package hr.infomare.drrh.pojo;

// Generated 16.06.2011. 15:40:00 by Hibernate Tools 3.2.1.GA

import hr.infomare.drrh.pomocni.PomocnaDatum;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import budgetuserlibrary.gw.fmis.ibm.hr.infotypes.MessageHeader;
import budgetuserlibrary.gw.fmis.ibm.hr.infotypes.ResponseMessageType;

/**
 * Resmsg generated by hbm2java
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "RESMSG")
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
public class Resmsg implements java.io.Serializable {

	private Long resmsgid;
	private String msgname;
	private String resmsgtype;
	private Long eventlid;
	private Date submdati;
	private Date submtime;
	private Integer reqmsgid;

	public Resmsg() {
	}

	@Id
	@Column(name = "RESMSGID", unique = true, nullable = false, precision = 9, scale = 0)
	public Long getResmsgid() {
		return this.resmsgid;
	}

	public void setResmsgid(Long resmsgid) {
		this.resmsgid = resmsgid;
	}

	@Column(name = "MSGNAME", nullable = false, length = 120)
	public String getMsgname() {
		return this.msgname;
	}

	public void setMsgname(String msgname) {
		this.msgname = msgname;
	}

	@Column(name = "RESMSGTYPE", nullable = true, length = 120)
	public String getResmsgtype() {
		return this.resmsgtype;
	}

	public void setResmsgtype(String resmsgtype) {
		this.resmsgtype = resmsgtype;
	}

	@Column(name = "EVENTLID", nullable = true, precision = 9, scale = 0)
	public Long getEventlid() {
		return this.eventlid;
	}

	public void setEventlid(Long eventlid) {
		this.eventlid = eventlid;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "SUBMDATI", nullable = false, length = 10)
	public Date getSubmdati() {
		return this.submdati;
	}

	public void setSubmdati(Date submdati) {
		this.submdati = submdati;
	}

	@Temporal(TemporalType.TIME)
	@Column(name = "SUBMTIME", nullable = false, length = 8)
	public Date getSubmtime() {
		return this.submtime;
	}

	public void setSubmtime(Date submtime) {
		this.submtime = submtime;
	}

	@Column(name = "REQMSGID", precision = 9, scale = 0)
	public Integer getReqmsgid() {
		return this.reqmsgid;
	}

	public void setReqmsgid(Integer reqmsgid) {
		this.reqmsgid = reqmsgid;
	}

	public void postaviVrijednosti(MessageHeader messageHeader, String msgName,
			ResponseMessageType resMsgType, Reqmsg reqMsg) {
		this.resmsgid = messageHeader.getResponseMsgId();
		this.msgname = msgName;
		this.resmsgtype = resMsgType.value();
		this.eventlid = messageHeader.getEventId();
		if (reqMsg != null) {
			reqmsgid = reqMsg.getReqmsgid();
		}
		this.submdati = PomocnaDatum.XMLDatumUDate(messageHeader
				.getSubmitionTimestamp());
		this.submtime = PomocnaDatum.XMLDatumUDate(messageHeader.getSubmitionTimestamp());		
	}	
}